﻿//  --------------------------------
//  Copyright (c) PK Logix LLC. All rights reserved.
//  This source code is made available under the terms of the GNU General Public License version 2 (GPLv2)
//  http://www.codeplex.com/mvcclubsite/license
//  ---------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MVCClubSite.BLL;
using MVCClubSite.IDAL;
using System.Configuration;
using MVCClubSite.Helpers;
using MVCClubSite.Web.ViewData;


namespace MVCClubSite.Web.Controllers
{
    [HandleError]
    public class HomeController : BaseController
    {
        AnnouncementsService _announcementService;
        EventsService _eventsService;

        public HomeController()
            : this(null, null)
        {
        }

        public HomeController(AnnouncementsService announcementService, EventsService eventsService)
        {
            _announcementService = announcementService ?? new AnnouncementsService();
            _eventsService = eventsService ?? new EventsService();
        }

        public ActionResult Index()
        {
            HomeViewData data = new HomeViewData();
            data.Announcements = _announcementService.GetRecentAnnouncements(Config.Announcements.PageSize);
            data.UpcomingEvents = _eventsService.GetUpcomingEvents(Config.Events.RecentCount);
            data.RecentEvents = _eventsService.GetRecentEvents(Config.Events.RecentCount);
            return View("Index", data);
        }

        public ActionResult About()
        {
            ViewData["Title"] = "About Page";

            return View("About");
        }

        
    }
}
